package cn.hd.service.impl;

import cn.hd.dao.AdvertiseDao;
import cn.hd.entity.Advertise;
import cn.hd.service.AdvertiseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class AdvertiseServiceImpl implements AdvertiseService {
    @Autowired
    private AdvertiseDao advertiseDao;

    @Override
    public PageInfo<Advertise> selectAdvertise(int pageNum, int pageSize, Map map) {
        PageHelper.startPage(pageNum,pageSize);
        List<Advertise> advertises = advertiseDao.selectAdvertise(map);
        PageInfo<Advertise> pageInfo=new PageInfo<>(advertises);
        return pageInfo;
    }

    @Override
    public PageInfo<Advertise> selectAllFenYeAdvertise(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Advertise> advertises = advertiseDao.selectAllAdvertise();
        PageInfo<Advertise> pageInfo=new PageInfo<>(advertises);
        return pageInfo;
    }

    @Override
    public int addAdvertise(Advertise advertise) {
        int i = advertiseDao.addAdvertise(advertise);
        return i;
    }

    @Override
    public Advertise selectAdvertiseById(long adid) {
        Advertise advertise = advertiseDao.selectAdvertiseById(adid);
        return advertise;
    }

    @Override
    public int updateAdvertise(Advertise advertise) {
        int i = advertiseDao.updateAdvertise(advertise);
        return i;
    }

    @Override
    public int deleteAdvertise(long adid) {
        int i = advertiseDao.deleteAdvertise(adid);
        return i;
    }

    @Override
    public int updateAdvertisePass(long adid) {
        return advertiseDao.updateAdvertisePass(adid);
    }

    @Override
    public int updateAdvertiseFail(long adid) {
        return advertiseDao.updateAdvertiseFail(adid);
    }
}
